function index = ijk2index(i,j,k,i_d,j_d)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Given the index in a 3D matrix (i,j,k), calculate the index 
%%
%% Inputs:  1. i1
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

index = (i-1)*(i_d-1) + (k-1) + (j-1) + (k-1)*(j_d-1);

